/*
 * Copyright 2003-2005 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

#ifndef TYPEOUTPUTSTREAM
#define TYPEOUTPUTSTREAM

#ifdef __cplusplus
extern "C" {
#endif


typedef int (*argot_write)( type_output_stream * out, void * data, char * buffer, int size );

/* data structure for input stream.
 * 
 * 
 */
struct type_output_stream
{
	void * data;  /* private data for functions */
	argot_error * error; /* error reporting */
	type_map * map; /* type map */
	argot_write write_buffer; /* function to read buffer */
};
 

/* Create a input structure */
void type_output_init( type_output_stream *, type_map * map, argot_write ag, void * data );

/* Destroy a input structure */
void type_output_destroy( type_output_stream * tis );

/* Set an error on the stream */
void type_output_set_error( type_output_stream * tis, int rc );

/* Get/Check error on stream. Returns NULL if no error */
argot_error * type_output_get_error( type_output_stream * tis );

/* Read a single byte from the stream */
#define type_output_write_byte( tis, b ) ((tis)->write_byte((b)))

/* Read a buffer from the stream */
#define type_output_write_buffer( tis, buffer, size ) ((tis)->write_buffer( (tis), (tis)->data, (buffer), (size) ))

/* Get the type map for the stream */
#define type_output_type_map( tis ) ((tis)->map)

/* Write an object using the system id from the stream */
int type_output_write_object( type_output_stream * tis,int systemId, void * object );

/* Write an object using the object name */
int type_output_write_named_object( type_output_stream * tis, type_name * name, void * object );


#define type_output_write_u16( out, u16 ) type_output_write_named_object( (out), &uint16_name, &(u16) )

#ifdef __cplusplus
}
#endif

#endif
